package brave;

import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;

public class BlockListener implements Listener
{
	@EventHandler
	public void onBlockBreak(BlockBreakEvent event)
	{
		String playerName = event.getPlayer().getName();
		WallPlayer player = Brave.getWallPlayer(event.getPlayer());
		
		// TODO: remove exceptions list of exceptions
		if (playerName.equalsIgnoreCase("joan_of_arc12") ||
				playerName.equalsIgnoreCase("antonio_corelli"))
		{
			return;
		}

		if (player.getState() == WallPlayerState.DEFAULT ||
				player.getState() == WallPlayerState.OBSERVING_GAME)
		{
			event.setCancelled(true);
		}
	}
	
	@EventHandler
	public void onBlockPlace(BlockPlaceEvent event)
	{
		String playerName = event.getPlayer().getName();
		WallPlayer player = Brave.getWallPlayer(event.getPlayer());

		// TODO: remove exceptions list of exceptions
		if (playerName.equalsIgnoreCase("joan_of_arc12") ||
				playerName.equalsIgnoreCase("antonio_corelli"))
		{
			return;
		}
		

		if (player.getState() == WallPlayerState.DEFAULT ||
				player.getState() == WallPlayerState.OBSERVING_GAME)
		{
			event.setCancelled(true);
		}
	}
}
